package com.magicborrow.views;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.magicborrow.R;

/**
 * Created by ronaldo on 2016/6/2.
 */
public class MagicDialog extends Dialog{

    private TextView tvMsg;
    private TextView tvOk;
    private TextView tvCancel;
    private String msg;
    private Context mContext;

    public MagicDialog(Context context) {
        super(context);
    }

    public MagicDialog(Context context, String msg) {
        super(context, R.style.magic_Dialog);
        this.mContext=context;
        this.msg = msg;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_magic);
        tvCancel = (TextView) findViewById(R.id.tvcancel_e);
        tvOk = (TextView) findViewById(R.id.tvok_e);
        tvMsg = (TextView) findViewById(R.id.tv_msg_e);
        tvMsg.setText(msg);
    }

    public void setOnButtonClickListener(final OnButtonClickListener onButtonClickListener){
        tvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onButtonClickListener.onCancelClick(MagicDialog.this);
            }
        });
        tvOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onButtonClickListener.onOkClick(MagicDialog.this);
            }
        });
    }

    public interface OnButtonClickListener{
        void onOkClick(Dialog dialog);
        void onCancelClick(Dialog dialog);
    }


}
